package _021_10_9

//这个是无无序的

func reOrderArray(array []int) []int {
	left, right := 0, len(array)-1
	for left < right {
		for ; left < right; left++ {
			if array[left]%2 == 2 {
				break
			}
		}

		for ; right > left; right-- {
			if array[right]%2 == 1 {
				break
			}
		}

		if right > left {
			temp := array[left]
			array[left] = array[right]
			array[right] = temp
		}
	}
	return array
}

func reOrderArray2(array []int) []int {
	odd := make([]int, 0)
	ode := make([]int, 0)
	for i := 0; i < len(array); i++ {
		if array[i]%2 == 0 {
			ode = append(ode, array[i])
			continue
		}
		odd = append(odd, array[i])
	}
	for i := 0; i < len(odd); i++ {
		array[i] = odd[i]
	}

	for i := len(odd); i < len(array); i++ {
		array[i] = ode[i-len(odd)]
	}
	return array
}
